/*   1:    */ package com.atomikos.datasource.xa;
/*   2:    */ 
/*   3:    */ import java.io.Serializable;
/*   4:    */ import java.util.Arrays;
/*   5:    */ import javax.transaction.xa.Xid;
/*   6:    */ 
/*   7:    */ public class XID
/*   8:    */   implements Serializable, Xid
/*   9:    */ {
/*  10:    */   private static final long serialVersionUID = 4796496938014754464L;
/*  11:    */   private String meAsString_;
/*  12:    */   private int formatId_;
/*  13: 49 */   private int branchUsed_ = 0;
/*  14: 51 */   private int globalUsed_ = 0;
/*  15: 53 */   private byte[] branchQualifier_ = new byte[64];
/*  16: 55 */   private byte[] globalTransactionId_ = new byte[64];
/*  17:    */   private static final int DEFAULT_FORMAString = 1096044365;
/*  18:    */   
/*  19:    */   private XID(String tid)
/*  20:    */   {
/*  21: 65 */     this.formatId_ = 1096044365;
/*  22: 66 */     this.branchQualifier_[0] = 0;
/*  23: 67 */     this.branchUsed_ = 1;
/*  24: 68 */     this.globalTransactionId_ = tid.toString().getBytes();
/*  25: 69 */     this.globalUsed_ = tid.toString().getBytes().length;
/*  26:    */   }
/*  27:    */   
/*  28:    */   public XID(String tid, String resourceURL)
/*  29:    */   {
/*  30: 88 */     this(tid);
/*  31: 89 */     this.branchQualifier_ = resourceURL.getBytes();
/*  32: 90 */     this.branchUsed_ = this.branchQualifier_.length;
/*  33: 91 */     if (this.branchQualifier_.length > 64) {
/*  34: 92 */       throw new RuntimeException("Max branch qualifier length exceeded.");
/*  35:    */     }
/*  36: 94 */     if (this.globalUsed_ > 64) {
/*  37: 95 */       throw new RuntimeException("Max global tid length exceeded.");
/*  38:    */     }
/*  39:    */   }
/*  40:    */   
/*  41:    */   public XID(Xid xid)
/*  42:    */   {
/*  43:110 */     this.formatId_ = xid.getFormatId();
/*  44:111 */     this.globalTransactionId_ = xid.getGlobalTransactionId();
/*  45:112 */     this.globalUsed_ = xid.getGlobalTransactionId().length;
/*  46:113 */     this.branchQualifier_ = xid.getBranchQualifier();
/*  47:114 */     this.branchUsed_ = xid.getBranchQualifier().length;
/*  48:    */   }
/*  49:    */   
/*  50:    */   public int getFormatId()
/*  51:    */   {
/*  52:119 */     return this.formatId_;
/*  53:    */   }
/*  54:    */   
/*  55:    */   public byte[] getBranchQualifier()
/*  56:    */   {
/*  57:124 */     return this.branchQualifier_;
/*  58:    */   }
/*  59:    */   
/*  60:    */   public byte[] getGlobalTransactionId()
/*  61:    */   {
/*  62:129 */     return this.globalTransactionId_;
/*  63:    */   }
/*  64:    */   
/*  65:    */   public boolean equals(Object obj)
/*  66:    */   {
/*  67:134 */     if (this == obj) {
/*  68:135 */       return true;
/*  69:    */     }
/*  70:136 */     if (obj == null) {
/*  71:137 */       return false;
/*  72:    */     }
/*  73:138 */     if (getClass() != obj.getClass()) {
/*  74:139 */       return false;
/*  75:    */     }
/*  76:140 */     Xid xid = (Xid)obj;
/*  77:    */     
/*  78:    */ 
/*  79:    */ 
/*  80:    */ 
/*  81:    */ 
/*  82:    */ 
/*  83:    */ 
/*  84:    */ 
/*  85:149 */     return (Arrays.equals(xid.getGlobalTransactionId(), getGlobalTransactionId())) && (Arrays.equals(xid.getBranchQualifier(), getBranchQualifier()));
/*  86:    */   }
/*  87:    */   
/*  88:    */   public String toString()
/*  89:    */   {
/*  90:155 */     if (this.meAsString_ == null) {
/*  91:156 */       this.meAsString_ = (new String(getGlobalTransactionId()) + new String(getBranchQualifier()));
/*  92:    */     }
/*  93:159 */     return this.meAsString_;
/*  94:    */   }
/*  95:    */   
/*  96:    */   public int hashCode()
/*  97:    */   {
/*  98:164 */     return toString().hashCode();
/*  99:    */   }
/* 100:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.datasource.xa.XID
 * JD-Core Version:    0.7.0.1
 */